#
# # 1、求 1~100 的和
# theSum = 0
# for i in range(1, 11):
#     theSum += i
# print(theSum)
#
# # 2、求 300~400 的和
# theSum = 0
# for i in range(300, 401):
#     theSum += i
# print(theSum)
#
# # 3、求 1~1000 的和
# theSum = 0
# for i in range(1, 1001):
#     theSum += i
# print(theSum)

# # 定义一个数列求和函数
# def CalcSum(beg, end):
#     theSum = 0
#     for i in range(beg, end + 1):
#         theSum += i
#     print(theSum)
#
# # 调用函数
# # 1、求 1~100 的和
# CalcSum(1, 100)
# # 2、求 300~400 的和
# CalcSum(300, 400)
# # 3、求 1~1000 的和
# CalcSum(1, 1000)

# Test() # 还没有执行到定义，就先执行调用了，此时就会报错
#
# def Test():
#     print('hello world')

# def Test():
#     print('hello world')
#
# # 函数调用才会真正执行函数体里面的代码
# # 函数经过一次定义之后，可以被调用多次
# Test()
# Test()
# Test()

# def Add(x, y):
#     return x + y
#
# print(Add(10, 20))
# print(Add(1.5, 2.5))
# print(Add('hello', ' world'))

# def CalcSum(beg, end):
#     theSum = 0
#     for i in range(beg, end + 1):
#         theSum += i
#     return theSum
#
# result = CalcSum(1, 100)
# print(result)

# def CalcSum(beg, end):
#     theSum = 0
#     for i in range(beg, end + 1):
#         theSum += i
#     print(theSum)
#
# CalcSum(1, 100)

# # 判断奇数
# def IsOdd(num):
#     if num % 2 == 0:
#         return False
#     else:
#         return True

# # 判断奇数
# def IsOdd(num):
#     if num % 2 == 0:
#         return False
#     return True

# # 写一个函数，返回横纵坐标
# def GetPoint():
#     x = 10
#     y = 20
#     return x, y
#
# a, b = GetPoint()

# # 写一个函数，返回横纵坐标
# def GetPoint():
#     x = 10
#     y = 20
#     return x, y
#
# _, b = GetPoint()

# # 写一个函数，返回横纵坐标
# def GetPoint():
#     x = 10
#     y = 20
#     return x, y
#
# print(x, y)

# x = 10
#
# def Test():
#     x = 10
#     print(f'函数内部 x = {x}')
#
# Test()
# print(f'函数外部 x = {x}')

# x = 10
#
# def Test():
#     print(f'x = {x}')
#
# Test()

# x = 10
#
# # 使用这个函数，把全局变量 x 的值改成 20
# def Test():
#     global x
#     x = 20

# if True:
#     x = 10
#
# print(x)  # 10

# # 定义一个数列求和函数
# def CalcSum(beg, end):
#     theSum = 0
#     for i in range(beg, end + 1):
#         theSum += i
#     print(theSum)
#
# # 调用函数
# # 1、求 1~100 的和
# CalcSum(1, 100)
# # 2、求 300~400 的和
# CalcSum(300, 400)
# # 3、求 1~1000 的和
# CalcSum(1, 1000)

# def Test():
#     print('执行函数内部代码')
#     print('执行函数内部代码')
#     print('执行函数内部代码')
#
# print('111')
# Test()
# print('222')
# Test()
# print('333')

# 判断是否是奇数
# def IsOdd(num):
#     if num % 2 == 0:
#         return False
#     else:
#         return True
#
# ret = IsOdd(10)
# print(ret)

# # 判断是否是奇数
# def IsOdd(num):
#     if num % 2 == 0:
#         return False
#     else:
#         return True
#
# print(IsOdd(10))

# def a():
#     print("函数 a")
#
# def b():
#     print("函数 b")
#     a()
#
# def c():
#     print("函数 c")
#     b()
#
# def d():
#     print("函数 d")
#     c()
#
# d()

# def a():
#     print("函数 a")
#
# def b():
#     a()
#     print("函数 b")
#
# def c():
#     b()
#     print("函数 c")
#
# def d():
#     c()
#     print("函数 d")
#
# d()

# def Factor(n):
#     if n == 1:
#         return 1
#     else:
#         return n * Factor(n-1)
#
# print(Factor(5))

# def Factor(n):
#     return n * Factor(n - 1)
#
# print(Factor(5))

# def Add(x, y, debug = False):
#     if debug:
#         print(f'x = {x}，y = {y}')
#     print(x + y)
#
# Add(10, 20)
# Add(10, 20, True)

# def Add(x, debug = False, y):
#     if debug:
#         print(f'x = {x}，y = {y}')
#     print(x + y)

# def Test(x, y):
#     print(f'x = {x}')
#     print(f'y = {y}')
#
# Test(x = 10, y = 20)
# Test(y = 20, x = 10)






























